package com.njwb.io;

import java.io.*;

/**
 * Description: 类的描述
 * Author: yuandeyin@itany.com
 * Date: 2025-08-05 11:45
 * Version: 1.0
 */
public class TestFileInputStream {
    public static void main(String[] args) {
        //1.定义一个输入流
        InputStream in = null;

        //2.实例化对象
        try {
//            in = new FileInputStream("src/com/njwb/io/hello.txt");
            in = new FileInputStream(new File("src/com/njwb/io/hello.txt"));

            //3.每次读取一个字节
            int data = in.read();
            while(data != -1){
                System.out.print((char)data);
                data = in.read();
            }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }finally {
            if(null != in){
                try {
                    in.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}
